<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<input type="button" value="调用 androidTestFunction1" onclick="toAndroidFunction1()">
<input type="button" value="调用 androidTestFunction2" onclick="toAndroidFunction2()">

<script>
    /*
        这里window.AndroidJSBridge能调用的方法是
        D:\x\hybrid_tutorial\HybridAppDemo\app\src\main\java\cn\sunday\hybridappdemo\jsInterface\MyJaveScriptInterface.java
        提供的
    */
    function toAndroidFunction1(){
        window.AndroidJSBridge.androidTestFunction1('调用 android 下的 function1方法')
    }

    function toAndroidFunction2(){
        var result = window.AndroidJSBridge.androidTestFunction2('调用 android 下的 function1方法')
        alert(result)
    }


    /*
        下面在window上绑定了一个方法 是因为
        D:\x\hybrid_tutorial\HybridAppDemo\app\src\main\java\cn\sunday\hybridappdemo\MainActivity.java
        文件中

        public void onJSFunction1 (View v) {
        mWebView.evaluateJavascript("javascript:onFunction('android调用JS方法')", new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String s) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setMessage(s);
                    builder.setNegativeButton("确定", null);
                    builder.create().show();
                }
            });
        }
    */
    window.onFunction = function(str){
        alert(str);
        return 'onFunction 方法的返回值'
    }

</script>
</body>
</html>